package com.taotao.manage.exception;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SSMExceptionHandlerResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        SSMException ssme=null;
        if(ex instanceof SSMException){
            ssme= (SSMException) ex;
        }else {
            ex.printStackTrace();
            ssme=new SSMException("未知异常!");
        }
        ModelAndView mav=new ModelAndView();
        mav.addObject("message",ssme.getMessage());
        mav.setViewName("error/error");
        return mav;
    }
}
